Skip to content

Keep caption files uploaded before 2.8.0 - #2351

Merged
subodhr258 merged 3 commits into
mainfrom
fix/keep-earlier-caption-uploads
Nov 10, 2026
Merged

subodhr258 merged 3 commits into
mainfrom
fix/keep-earlier-caption-uploads

Conversation

@subodhr258

@subodhr258 subodhr258 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Part of the 2.8.0 release: https://github.com/rtCamp/godam-plugin-wp/issues/92

Problem

2.8.0 marks a caption file uploaded in WordPress with the rtgodam_transcript_source meta set to upload, so GoDAM Central's caption changes never replace it. Uploads made on 2.7.0 or earlier have no such mark. After the update they were treated as a cached copy of Central's caption:

  • Player: Central now always returns its caption track list, even when it is empty, so the player showed only Central's tracks. The uploaded file stopped playing for visitors. This affects every plan.
  • Editor and video SEO data: opening the Transcription tab, or the background refresh, replaced the stored path with Central's default caption, or removed it when Central had none.

The file itself stayed in the Media Library, but the video no longer used it.

Fix

A transcript with no source mark counts as an upload when its address is not on Central's CDN. Central serves caption files only from gdcdn.us, so any other address is a file the site holds itself. The check reuses rtgodam_is_transcoder_file_url(), so the rtgodam_transcoder_file_hosts filter still covers a staging Central.

  • New Transcription::is_wordpress_upload( $path, $source ), used by the caption sync, the refresh, the video SEO queue, the transcription callback and the player template.
  • Generate marks a running job central-pending. The stored file (often an upload) is kept and played until Central reports a ready default caption, which then replaces it and is marked central. If the job fails, the upload stays. Before this, Generate cleared the mark, so a sync during the job, or after a failed one, removed the upload (found by Rudrakshi and Vishal in review).
  • Every write of Central's transcript (the sync, the callback, godam_get_transcript_path()) now marks it central. So the address check only decides for transcripts stored before 2.8.0, as Vishal suggested. The rtgodam_transcoder_file_hosts docblock says the hosts now also do this.

Not done: a one-time backfill on upgrade. It would be the same size of change, but it is an upgrade routine that runs per site on multisite. The check when the meta is read needs neither.

Tests

  • Added: an unmarked upload survives the sync and the refresh, Generate replaces it, and a table of is_wordpress_upload() cases (site file, S3 file, Central copy, generated).
  • The existing caption tests now use a gdcdn.us address for Central's files, as Central does.
  • TranscriptionGenerateSourceTest calls generate_transcription() with stubbed Central answers. It covers: a running job keeps the upload, an immediate transcript replaces it, a Pending or Failed default keeps it, a ready default replaces it, and the sync marks Central's copies.
  • With the old check put back, the 4 new upload tests fail. With the sync's pending rule removed, the 2 unfinished-job tests fail. With the fix, all 157 transcription, SEO and CDN-address tests pass, and the full suite has no failures other than PHP 8.5's setAccessible deprecation (CI uses 8.4). PHPCS is clean, and the changed files pass a PHP 7.4 syntax check.

QA steps

  1. On 2.7.0, upload a .vtt in the Transcription tab of a video GoDAM has transcoded. Check it plays on a page.
  2. Update to this build.
  3. Open the page: the uploaded captions still show by default.
  4. Open the video in the editor, then the Transcription tab: the uploaded file is still listed.
  5. The editor hides Generate while a file is attached, so start one from the browser console on that editor page: fetch( godamRestRoute.url + 'godam/v1/transcription/generate', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-WP-Nonce': godamRestRoute.nonce }, body: JSON.stringify( { attachment_id: <ID> } ) } ).then( ( r ) => r.json() ).then( console.log ). While the job runs, the page still plays the uploaded captions. When it finishes, opening the Transcription tab shows the generated transcript in place of the upload.
  6. Control: on a video with a generated (Central) transcript, change the default caption in Central. Opening the Transcription tab picks up the new default.

Risk: high. This decides whether stored transcript data is kept or replaced.

2.8.0 marks a caption file uploaded in WordPress with
rtgodam_transcript_source = upload, but uploads from earlier versions
have no mark. They were treated as a cached copy of GoDAM Central's
caption: opening the Transcription tab or the background refresh
overwrote or removed them, and the player played Central's tracks
instead.

An unmarked transcript whose address is not on Central's CDN now counts
as an upload. Generate marks the source as central, so a new
transcript still replaces an old upload.
@subodhr258 subodhr258 added the risk: high Full human QA and sign-off (security, data, Woo revenue, Central API) label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

🔍 WordPress Plugin Check Report

⚠️ Status: Passed with warnings

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
13 0 13

⚠️ Warnings (13)

📁 readme.txt (1 warning)
📍 Line 🔖 Check 💬 Message
0 mismatched_plugin_name Plugin name "GoDAM - Video Hosting for LMS & Online Courses" is different from the name declared in plugin header "GoDAM".
📁 assets/build/pages/video-editor.min.js (1 warning)
📍 Line 🔖 Check 💬 Message
2 react_removed_api This file calls "ReactDOM.findDOMNode", which was removed in React 19 and stops working once WordPress upgrades React. Use a ref on the element instead.
📁 assets/build/css/main.css (1 warning)
📍 Line 🔖 Check 💬 Message
0 EnqueuedStylesScope This style is being loaded in all contexts.
📁 assets/src/libs/analytics.min.js (5 warnings)
📍 Line 🔖 Check 💬 Message
0 EnqueuedScriptsScope This script is being loaded in all frontend contexts.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/2026/11/10/demo-post-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/demo-page-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead.
📁 assets/build/js/main.min.js (5 warnings)
📍 Line 🔖 Check 💬 Message
0 EnqueuedScriptsScope This script is being loaded in all frontend contexts.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/2026/11/10/demo-post-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/demo-page-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.
0 NonBlockingScripts.NoStrategy This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead.

🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@subodhr258
subodhr258 requested a review from elifvish November 10, 2026 08:51
@rudrakshi-gupta

Copy link
Copy Markdown
Member

Code review

Verdict: the fix is right. One small thing is needed before merge (the stale POT, which is why the check is red), and there's one data-loss path worth deciding on. Since 2.7.0 stored only a URL for an upload, with no other marker, the URL host is the only signal available, and routing every read through is_wordpress_upload() is the right shape.

What I ran

Check Result
TranscriptionCaption* tests 30/30 pass
Full PHPUnit 1381 tests pass
PHPCS on the changed files Clean
Translatable strings added or changed None
Every reader of the source mark All go through is_wordpress_upload(): the callback, the sync, the refresh, the SEO queue, and the player template (which normalizes to upload before printing data-transcript-source, so transcriptManager.js needs no change)

Needed before merge: regenerate languages/godam.pot

The Translation Template check fails because the POT records line numbers (#: inc/classes/rest-api/class-transcription.php:NNN), and the check only ignores POT-Creation-Date. This PR adds lines above most of that file's strings. I checked the committed POT's 20 references for class-transcription.php: on main all 20 point at a translation call, but on this branch 19 of 20 point at the wrong line. #2349 passed this check just before, so it isn't a pre-existing failure. The fix is npm run build:prod && composer pot, then commit languages/.

Worth deciding: Generate drops the upload before the new transcript exists

Generate now sets the source to central in the in-progress branch too. After that, sync_cached_transcript() treats the old upload as Central's cache. Central never lists the upload's URL, so whenever Central has no ready default, the path falls to delete_post_meta( 'rtgodam_transcript_path' ). I reproduced it with the PR's own refresh harness (throwaway test, deleted afterwards). The state was the user's upload with source central, and Central listing one default row with no file:

Central's default row After refresh_cached_default()
Pending (Generate still running, editor reopened) upload path deleted
Failed (Generate failed) upload path deleted, and stays gone

So during the transcription the video plays no captions, and if Generate fails the user's file is no longer used (it's still in the Media Library). To be fair, main already does this for uploads marked upload, because Generate clears the mark there, so this isn't a regression. But this PR now applies it to every pre-2.8 upload too, and QA step 5 ("when it finishes, the generated transcript replaces the upload") only describes the happy path. Some options:

  • In the in-progress branch, set something like central-pending that is_wordpress_upload() still treats as an upload for keeping it, and let the sync replace it only once Central reports a ready default. Then switch it to central in the ! empty( $path ) branch.
  • Or, in sync_cached_transcript(), keep an unlisted cached path while the status is in flight, and on Failed.

Nits (non-blocking)

  1. The https requirement: rtgodam_is_transcoder_file_url() requires https because Download transcoded files only from GoDAM CDN hosts, and read the callback API key from the body #2248 uses it for downloads (SSRF). Here it only classifies, so a Central file stored as http://*.gdcdn.us/... would count as an upload. Comparing the host alone (using the same host list) would be a safer test for "is this Central's file".
  2. The underlying assumption: the heuristic relies on every account's cdn_zone_url being under gdcdn.us. That isn't hardcoded in godam-core; it comes from provisioning. It's the same assumption Download transcoded files only from GoDAM CDN hosts, and read the callback API key from the body #2248's allowlist rests on, which has already shipped, so I'm fine with it. Worth one line in the release notes, though: a site on a Central whose CDN isn't in rtgodam_transcoder_file_hosts would have its old generated transcripts treated as uploads, and adding the host fixes it.
  3. Skipping the one-time backfill makes sense. The read-time check also covers sites that update without visiting wp-admin.

Review drafted with Claude.

@subodhr258

subodhr258 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

Thanks for the review, Rudrakshi.

POT: regenerated and pushed in 1682c73. It was built with Node 22.14.0 from .nvmrc, and both make-pot passes ran with --slug=godam. Only the 20 class-transcription.php line references changed.

Generate dropping the upload: fixed after all in 60eaf02, with your central-pending idea, since Vishal found the same thing. Generate marks a running job central-pending, the stored file is kept and played until Central reports a ready default, and a Pending or Failed default leaves it alone. TranscriptionGenerateSourceTest covers it.

Nits:

  1. https: Central only hands out https caption URLs, and getting it wrong errs on the safe side: an http Central file would be kept and not refreshed, never deleted. I'll leave it as it is.
  2. CDN host assumption: agreed. I'll add the rtgodam_transcoder_file_hosts line to the release notes.
  3. Backfill: agreed.

@elifvish elifvish left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Reading the mark at read time is the right call: it needs no upgrade routine and it covers sites that update without opening wp-admin. I reviewed it on 1682c73 (the POT-only commit on top of 2ed733d). Nothing here blocks the merge, but there is one Generate behaviour worth deciding on first.

Security
No issues found. There is no new input, route or permission change, and is_wordpress_upload() only reads two metas and fails safe. Look-alike hosts (evilgdcdn.us) and userinfo tricks (x.gdcdn.us@evil.example) count as "not Central", so the file is kept rather than overwritten. The transcription callback's API-key check is unchanged.

Correctness

  1. Generate drops the old file before the new transcript exists (inline on class-transcription.php:589). After Generate is accepted, the sync treats the old upload as Central's cache. If Central has no ready default file at that point (row still pending, or the job failed), the sync deletes rtgodam_transcript_path. I reproduced it with a stubbed Central answer; I did not confirm against a live Central that it lists a pending default row while the job runs. It is not new for uploads marked upload, but this PR now applies it to every pre-2.8.0 upload, and QA step 5 only covers the happy path. Rudrakshi raised the same thing earlier; I got to it independently.
  2. The Generate half of the fix has no test (inline on TranscriptionCaptionSyncTest.php). With Generate's two SOURCE_CENTRAL writes put back to delete_post_meta(), all 30 caption tests still pass, but a script that calls generate_transcription() fails.

Other
3. The host check will keep deciding for every Central copy from now on, because the sync writes Central's path without a mark. It also requires https, which only makes sense for the download guard (inline on class-transcription.php:854). The filter docblock in custom-functions.php (line 3558) should say it now also decides upload vs Central copy.

Consumer impact

  • The player (transcriptManager.js) needs no change, because the template now supplies upload for unmarked uploads. The transcript panel and the audio block read the path only, so they are unaffected.
  • The editor Transcription tab keeps the same response shape. The SEO queue now skips unmarked uploads (intended). The older-Central callback branch has the same semantics with the new classifier.
  • godam-core, godam-upload, godam-transcoder and godam-analytics don't read these metas. I did not check godam-for-woo, godam-ai, the desktop app or the iOS apps.

Verification

  • Environment: PHP 8.2.35 container with PHPUnit 9.6.33 (CI uses 8.4). Commit 2ed733d, then re-run on 1682c73 after the head moved. That commit changed only languages/godam.pot.
  • PHPUnit: the Transcription tests pass 30/30. The full suite minus SiteOriginTest ran 1300 tests with 3929 assertions, 0 failures and 2 skipped. SiteOriginTest is excluded because the container has no ext-intl; this PR doesn't touch it.
  • Your claim holds: with the old 'upload' === $source rule restored, 4 new tests fail (sync, refresh and 2 dataset rows). All 30 pass with the fix.
  • A probe script I wrote, not part of the PR, calls generate_transcription() with stubbed Central answers and then runs the sync. All 6 Generate/sync checks and 14 classification checks pass at head.
  • PHPCS is clean on the 6 changed PHP files, and php -l is clean on PHP 8.2. I had no 7.4 binary and read the code for 7.x-incompatible syntax. CI on 1682c73 is green, including the POT and Plugin Check jobs.
  • I read godam-core. Caption URLs come from the account's cdn_zone_url and signing keeps the host. get_public_transcription_path returns caption_tracks in both branches.
  • Not covered: no browser or live-WordPress run (no WordPress site or UI login on the review host), so I haven't seen the player or Transcription tab on a page and QA steps 1 to 6 were not walked. No live Central. No PHP 7.4 or 8.4 run. Production cdn_domain values were not checked.

Generate marked the transcript as Central's as soon as a job started,
so while the job ran, or after it failed, the caption sync saw an
unlisted Central copy and removed the uploaded file the video used.

Generate now marks a running job central-pending: the stored file is
kept and played as an upload until Central reports a ready default,
which then replaces it and marks it central. Every write of Central's
transcript (sync, callback, godam_get_transcript_path) now marks it
central too, so the address check only decides for transcripts stored
before 2.8.0. The rtgodam_transcoder_file_hosts docblock says so.

Regenerate godam.pot for the shifted line references.
@subodhr258
subodhr258 requested review from elifvish and removed request for elifvish November 10, 2026 09:38
@rudrakshi-gupta

Copy link
Copy Markdown
Member

Re-review

Verdict: LGTM. Both items from my review are resolved, and nothing blocks the merge. I checked head 60eaf02 locally.

Resolved

Earlier item Now
Stale POT Regenerated in 1682c73 and refreshed again in 60eaf02 after the later edits. The only POT changes are references; no strings changed. All 20 refs for class-transcription.php and 29 for custom-functions.php point at their translation calls on the final branch. Translation Template is green, along with the other 8 checks.
Generate dropping the upload Fixed with central-pending. I re-ran my earlier throwaway repro against the new state. The upload is now kept while Central's default is Pending, and also after it's Failed.

Extra cases I tried (throwaway tests, deleted afterwards)

  • A ready default replaces the stored file and switches the mark from central-pending to central, including a signed ?token= URL.
  • A file uploaded while a job runs (upload) is not overwritten when that job finishes.
  • central-pending with nothing stored is not treated as an upload, and Central's list still applies (takes_central_transcript() is true).

Runs

Check Result
TranscriptionCaption* + new TranscriptionGenerateSourceTest 38/38 pass
Full PHPUnit 1389 tests pass
PHPCS on the changed files Clean

I also like that godam_get_transcript_path() and the older-Central callback now stamp central, so the host check really is limited to pre-2.8 rows. Your replies on the https nit and the CDN-host release-note line work for me.

One optional follow-up (not for this PR)

If Generate fails on a video whose stored file was already one of Central's copies, and Central makes the failed AI row the default, the mark stays central-pending. The old Central copy is then played as an "upload": it's shown first, appears again in the CC menu next to its Central track, and doesn't follow Central's default until a ready default appears. That's harmless and arguably better than losing captions, but a failed-transcription callback could reset the mark to central when the stored path is on Central's CDN.


Review drafted with Claude.

@subodhr258

Copy link
Copy Markdown
Collaborator Author

Thanks for the re-review and the extra cases.

On the optional follow-up: agreed it's real, and I'm leaving it out. It needs Generate while one of Central's copies is already stored, and the editor only shows Generate when nothing is stored, so it takes a direct API call. Even then the video plays Central's own older file rather than losing captions.

If it's ever needed, the smallest fix is in is_wordpress_upload(): count central-pending as an upload only when the stored file is not on Central's CDN. A pending Central copy then plays as a normal Central track. That fits best with a future Regenerate button, which would make this state reachable.

@subodhr258
subodhr258 merged commit 5f3bdd6 into main Nov 10, 2026
9 checks passed
@subodhr258
subodhr258 deleted the fix/keep-earlier-caption-uploads branch November 10, 2026 09:51
subodhr258 added a commit that referenced this pull request Nov 11, 2026
* 2.8.0: Nov 10 date, transcription fixes, caption test ids, JSX runtime build (#2347)

* Move the 2.8.0 date to November 10, 2026

* Transcription: say it usually takes a few minutes, not 10-15

The message shown while an AI transcription runs said it usually takes
10-15 minutes. It usually finishes in a few minutes, so say that, and
that long videos take longer.

* Update the POT for the transcription time message

* Transcription: say it usually takes a few seconds

A preprod test on 9 Nov transcribed 140 seconds of audio in about
3 seconds, so 'a few minutes' was still too long.

* Caption manager: add test ids to the file inputs, row actions and add form

The add and replace file inputs had no id, name or test id, so E2E tests
could only reach them by position. Row actions were only reachable through
a row test id keyed by the caption's id, which a test cannot know ahead.

Rows also carry data-caption-language and data-caption-label, so a test can
find the row for a language or label.

* Regenerate the POT after the caption manager test ids

* Build: resolve react/jsx-runtime to WordPress's React in the admin pages

Packages bundled from node_modules (such as @wordpress/dataviews) import
react/jsx-runtime. The pages build bundled that package, inlining React 18's
element factory into 11 bundles. Elements were then created by a different
copy of React from the one rendering them, and Plugin Check 2.2.0 fails the
build (inlined_react_jsx_runtime), which blocks merges to main.

Resolve the import to pages/jsx-runtime.js, which creates elements with
createElement from the externalized React global. WordPress registers a
shared react-jsx-runtime script only from 6.6, and GoDAM supports 6.5.

* Transcription: keep the cached transcript while the default has no file

Opening the Transcription tab asks Central for the caption list. When the
default caption had no file yet (an AI transcript still pending, or one
that failed), WordPress deleted its cached transcript, so the tab went
empty and the player lost it. Now the cached transcript stays while
Central still lists it; one Central no longer has is still cleared.

* Regenerate the POT after resolving react/jsx-runtime

* Regenerate the POT for the shifted transcription REST lines

* Transcription: say it usually takes a few minutes

"A few seconds" rested on one preprod run, and the panel polls every
8 seconds, so the note stays up longer than the job anyway.

Addresses review: #2347 (comment)

* Caption manager: one helper for a caption's display label

The label-or-language-name fallback was written in five places. It now
lives in captionDisplayLabel(), so data-caption-label and the visible
text can't drift apart. No behaviour change.

Addresses review: #2347 (comment)

* Regenerate the POT for the new transcription message

* Transcription: stop waiting and say why when GoDAM refuses to start

When Central refused a transcription, for example "Transcription limit
exceeded" on an account with no quota left, it gave the reason in
message and left error empty. The editor only read error, so it showed
nothing and kept the spinner running, polling every 8 seconds with no end.

getGenerateRefusal() now treats any success: false answer with no job
running as final and returns error or message. The editor stops waiting
and shows it, or a generic message when Central gave none.

* Regenerate the POT for the transcription refusal fix

* POT: restore the plugin slug in the bug-report header

The last two POT regenerations ran from worktree folders whose names
became the slug in Report-Msgid-Bugs-To. Regenerated with --slug=godam.

* Transcription: compare caption files, not signed URLs; keep an in-flight status

Central signs caption URLs with a fresh token on every request, so the
cached URL never equalled the listed one and the cache was still deleted
on accounts with signed delivery. Compare the file part, before the query
string. Also keep an in-flight status such as Transcribing when nothing
is cached, so the tab opens on the progress state.

Addresses review: #2347 (comment)
Addresses review: #2347 (comment)

* Regenerate the POT for the shifted transcription REST lines

* Keep caption files uploaded before 2.8.0 (#2351)

* Keep caption files uploaded before 2.8.0

2.8.0 marks a caption file uploaded in WordPress with
rtgodam_transcript_source = upload, but uploads from earlier versions
have no mark. They were treated as a cached copy of GoDAM Central's
caption: opening the Transcription tab or the background refresh
overwrote or removed them, and the player played Central's tracks
instead.

An unmarked transcript whose address is not on Central's CDN now counts
as an upload. Generate marks the source as central, so a new
transcript still replaces an old upload.

* Regenerate godam.pot for the shifted transcription line numbers

* Keep the stored caption file until Generate finishes

Generate marked the transcript as Central's as soon as a job started,
so while the job ran, or after it failed, the caption sync saw an
unlisted Central copy and removed the uploaded file the video used.

Generate now marks a running job central-pending: the stored file is
kept and played as an upload until Central reports a ready default,
which then replaces it and marks it central. Every write of Central's
transcript (sync, callback, godam_get_transcript_path) now marks it
central too, so the address check only decides for transcripts stored
before 2.8.0. The rtgodam_transcoder_file_hosts docblock says so.

Regenerate godam.pot for the shifted line references.

* fix: move Node.js to a release patched for CVE-2026-111497

---------

Co-authored-by: Rudrakshi Gupta <109859631+rudrakshi-gupta@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Kuldip Chaudhary <64731232+KMchaudhary@users.noreply.github.com>
Co-authored-by: KMchaudhary <kuldipkumar.chaudhary@rtcamp.com>
Co-authored-by: rtBot <43742164+rtBot@users.noreply.github.com>
Co-authored-by: Immanuel Raj <iamimmanuelraj@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high Full human QA and sign-off (security, data, Woo revenue, Central API)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants